package com.xjggb.cloud.servlce;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.stereotype.Service;

@Service
public class PaymentService {


    /*
    * 正常访问
    * */
    public String paymentInfo_ok(Integer id){

    return "线程"+Thread.currentThread().getName()+"paymentInfo_ok"+"^_^"+id;
    }

    /*
    * 超时访问
    * */

    @HystrixCommand(fallbackMethod = "paymentInfo_timeOut",commandProperties = {
            @HystrixProperty(name ="execution.isolation.thread.timeoutInMilliseconds",value = "4000")
    })
    public String timeOut(Integer id){
        try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); }
        return "线程"+Thread.currentThread().getName()+"8001timeOut"+"^_^"+id+"耗时";

    }
    //出来问题扛罪的
    public String paymentInfo_timeOut(Integer id){
        return "线程"+Thread.currentThread().getName()+"8001paymentInfo_timeOut"+"/(ㄒoㄒ)/~~"+"异常处理";
    }


}
